//
//  FuturesTableViewCell.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/8/7.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "FuturesTableViewCell.h"
#import <UIImageView+WebCache.h>

@interface FuturesTableViewCell()

@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLab;
@property (weak, nonatomic) IBOutlet UILabel *singleLab;
@property (weak, nonatomic) IBOutlet UILabel *priceLab;
@property (weak, nonatomic) IBOutlet UILabel *countLab;
@property (weak, nonatomic) IBOutlet UILabel *buyTimeLab;
@property (weak, nonatomic) IBOutlet UILabel *fireTimeLab;
@property (weak, nonatomic) IBOutlet UILabel *statusLab;

@property (weak, nonatomic) IBOutlet UIButton *redeemBtn;
@property (weak, nonatomic) IBOutlet UIButton *secondsBtn;
@property (weak, nonatomic) IBOutlet UIButton *getWine;

@end
@implementation FuturesTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.clipsToBounds = YES;
}
- (IBAction)actionClick:(UIButton *)btn
{
    if ([self.delegate respondsToSelector:@selector(futuresTableViewCellClick:model:)]) {
        [self.delegate futuresTableViewCellClick:(FuturesActionType)btn.tag model:self.model];
    }
}

- (void)setModel:(MyFutureModel *)model
{
    _model = model;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.thumbnailUrl] placeholderImage:GetImage(@"default_goods_image")];
    self.nameLab.text = model.productName;
    self.singleLab.text = model.orderNo;
    self.priceLab.text = [NSString stringWithFormat:@"总价:¥%.2f",model.totalPrice];
    self.countLab.text = [NSString stringWithFormat:@"数量:%zd",model.productCount];
    self.buyTimeLab.text = [NSString stringWithFormat:@"购买日期:%@",model.createDate];
    self.fireTimeLab.text = [NSString stringWithFormat:@"到期日期:%@",model.endDate];
    self.getWine.enabled = model.isShowIWantWine;
    NSString *orderStatus;
    switch (model.status) {
        case 4:
        {
            orderStatus = @"已被他人购买";
            self.redeemBtn.enabled = NO;
            self.secondsBtn.enabled = NO;
        }
            break;
        case 5:
        {
            orderStatus = @"收益中";
            self.redeemBtn.enabled = YES;
            self.secondsBtn.enabled = YES;
        }
            break;
        case 6:
        {
            orderStatus = @"收益完成";
            self.redeemBtn.enabled = NO;
            self.secondsBtn.enabled = NO;
        }
            break;
        case 7:
        {
            orderStatus = @"已赎回";
            self.redeemBtn.enabled = NO;
            self.secondsBtn.enabled = NO;
        }
            break;
        case 8: //已放入二级市场
        {
            orderStatus = @"收益中";
            self.redeemBtn.enabled = NO;
            self.secondsBtn.enabled = NO;
        }
            break;
        case 9://赎回审核中
        {
            orderStatus = @"赎回审核中";
            self.redeemBtn.enabled = NO;
            self.secondsBtn.enabled = NO;
        }
            break;
        case 10://赎回审核失败
        {
            orderStatus = @"赎回审核失败";
            self.redeemBtn.enabled = YES;
            self.secondsBtn.enabled = YES;
        }
            break;
        case 11://赎回申请失败
        {
            orderStatus = @"收益中";
            self.redeemBtn.enabled = YES;
            self.secondsBtn.enabled = YES;
        }
            break;
        default:
            break;
    }
    if (model.isHalfStageCount == 1) {
        if (!self.getWine.enabled) {
            self.redeemBtn.enabled = NO;
            self.secondsBtn.enabled = NO;
        }
    }
    self.statusLab.text = [NSString stringWithFormat:@"%@",orderStatus];
}

@end
